Skip to content

Prevent temp file swapping in tx edit command.#2521

Merged
fnando merged 2 commits intomainfrom
tx-edit-toctou-fix
Apr 24, 2026
Merged

Prevent temp file swapping in tx edit command.#2521
fnando merged 2 commits intomainfrom
tx-edit-toctou-fix

Conversation

@fnando
Copy link
Copy Markdown
Member

@fnando fnando commented Apr 24, 2026

What

Prevent temp file swapping in tx edit command.

Why

Close https://github.com/stellar/stellar-cli-internal/issues/54

Known limitations

N/A

@fnando fnando self-assigned this Apr 24, 2026
Copilot AI review requested due to automatic review settings April 24, 2026 01:55
@fnando fnando added this to DevX Apr 24, 2026
@github-project-automation github-project-automation Bot moved this to Backlog (Not Ready) in DevX Apr 24, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens the stellar tx edit workflow by moving the editable JSON into a private temporary directory (instead of the current working directory), preventing unsafe temp-file behaviors (including swap/replace risks) while editing.

Changes:

  • Create the edit buffer file inside a tempfile::TempDir and keep the directory alive for the duration of the command.
  • Apply restrictive permissions on Unix (dir 0700, file 0600).
  • Add unit tests to verify tempdir usage and (on Unix) permission constraints.

@fnando fnando enabled auto-merge (squash) April 24, 2026 05:09
@fnando fnando merged commit a536ca4 into main Apr 24, 2026
210 checks passed
@fnando fnando deleted the tx-edit-toctou-fix branch April 24, 2026 05:17
@github-project-automation github-project-automation Bot moved this from Backlog (Not Ready) to Done in DevX Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants